<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>修改</title>
<link rel="stylesheet" href="${ctx }/resources/layui/css/layui.css" media="all" />
<link rel="stylesheet" href="${ctx }/resources/css/public.css" media="all" />
<link rel="stylesheet" type="text/css" href="${ctx }/resources/plugin/css/index.css">
<link rel="stylesheet" href="${ctx }/resources/layui/css/layui.css" media="all">
</head>
<body class="childrenBody">
	<form class="layui-form" action="#" id="frm" method="post" lay-filter="frm">
		<div class="layui-form-item">
    		<label class="layui-form-label">角色名称</label>
    		<div class="layui-input-block">
      			<input type="hidden" name="id" value="${role.id }">
      			<input type="text" name="name" id="name" lay-verify="required" autocomplete="off" 
      			 value="${role.name }" placeholder="请输入角色名称" class="layui-input">
   			</div>
 		 </div>
		<div class="layui-form-item layui-form-text">
			<label class="layui-form-label">角色备注</label>
			<div class="layui-input-block">
				<textarea class="layui-textarea" name="remark" 
				  lay-verify="remark" id="remark">${role.remark }</textarea>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">是否可用</label>
				<div class="layui-input-inline">
					<input type="radio" name="available" value="1" title="是" ${role.available==1?'checked':'' }>
					<input type="radio" name="available" value="0" title="否" ${role.available==0?'checked':'' }> 
				</div>
			</div>
		</div>

		<div class="layui-form-item">
			<div class="layui-input-block" style="text-align: center;">
				<!--lay-submit标记当按钮是一个提交按钮   -->
				<a href="javascript:void(0)" class="layui-btn" lay-submit=""  lay-filter="roleSubmit">提交</a>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
</body>
<script type="text/javascript" src="${ctx }/resources/layui/layui.js"></script>
<script type="text/javascript">
layui.use([ 'form','jquery','layer' ], function() {
	var form=layui.form;//得到form对象
	var $=layui.jquery;
	//创建一个编辑器
	/* var editIndex = layedit.build('content');
	form.verify({
	    content: function(value) { 
	    	layedit.getContent(editIndex);
	    	return layedit.sync(editIndex); //用于同步编辑器内容到textarea,参数 index 同build
	    }
	}); */
	//如果父页面有layer就使用父页的  没有就自己导入
	var layer = parent.layer === undefined ? layui.layer : parent.layer;
	//添加提交事件
	form.on("submit(roleSubmit)",function(data){
		var data=$("#frm").serialize();
		$.ajax({
			url:'${ctx}/role/updateRole.action?',
			type:'POST',
			async:true,    //异步
			data:data,
			timeout:5000,   //超时时间
			dataType:'json',   //返回的数据格式：json/xml/html/script/jsonp/text
			success:function(data){
            	layer.msg(data.msg);
                //关闭添加的弹出层
                var addIndex = parent.layer.getFrameIndex(window.name);
                window.parent.layer.close(addIndex);
                //刷新父页面的table
                window.parent.tableIns.reload();
            },
            error:function(xhr,textStatus){
            }
		})
		return false; 
	});
});	

	/* $(document).ready(function () {
       initDeptTree();
    });
	
	function initDeptTree() {
		//加载可用部门
		$.post("${ctx}/dept/loadDeptTree.action?available=1",function(zNodes){
			initSelectTree("pid",zNodes, false);
	        $(".layui-nav-item a").bind("click", function () {
	            if (!$(this).parent().hasClass("layui-nav-itemed") && !$(this).parent().parent().hasClass("layui-nav-child")) {
	                $(".layui-nav-tree").find(".layui-nav-itemed").removeClass("layui-nav-itemed")
	            }
	        })
		})
	} */
	

</script>
</html>